/*
浮点型数据是用来表示具有小数点的实数
- float型(单精度浮点型)
    - 编译系统为float型变量分配4个字节
    - 数值以规范化的二进制数指数形式存放
- double型(双精度浮点型)
    - 编译系统为double型变量分配8个字节
    - 15位有效数字
long double(长双精度)型
*/
#include <stdio.h>
int main()
{
    // 测试当前系统的数据长度
    printf("short=%d\n", sizeof(short));
    printf("int=%d\n", sizeof(int));
    printf("long=%d\n", sizeof(long));
    printf("float=%d\n", sizeof(float));
    printf("double=%d\n", sizeof(double));

    float x1 = 3.14159265358979323846264338327950288419716939937510582097944592307816406286208998;
    float y1;
    y1 = 2 * x1;
    printf("float: x1 = %26.22f, y1 = %26.22f \n", x1, y1);
    // float: x1 =   3.1415927410125732000000, y1 =   6.2831854820251465000000
    //                       ^ 开始错误，正确 6 位小数

    double x2 = 3.14159265358979323846264338327950288419716939937510582097944592307816406286208998;
    double y2;
    y2 = 2 * x2;
    printf("double: x2 = %26.22f, y2 = %26.22f \n", x2, y2);
    // double: x2 =   3.1415926535897931000000, y2 =   6.2831853071795862000000
    //                                 ^ 开始错误，正确 15 位小数

    long double x3 = 3.14159265358979323846264338327950288419716939937510582097944592307816406286208998;
    long double y3;
    y3 = 2 * x3;
    printf("long double: x3 = %26.22f, y3 = %26.22f \n", x3, y3);
    // long double: x3 = -88796093704928900000000000000000000000000000.0000000000000000000000, y3 =   0.0000000000000000000000
    // 错误
    return 0;
}